Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - add bracketed date support when composing new entry (#1915) #1918

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

chwt
Copy link

@chwt chwt commented Sep 24, 2024

Bracketed dates like [2020-01-01] at the beginning of an entry will be parsed and used as the entry date, thus be removed from the entry text.

Colon : and starred * usage is mostly covered too, see test cases.

Fixes #1915

Checklist

  • I have read the contributing doc.
  • I have included a link to the relevant issue number.
  • I have checked to ensure there aren't other open pull requests
    for the same issue.
  • I have written new tests for these changes, as needed.

…rg#1915)

Bracketed dates like [2020-01-01] will be parsed and used as the entry date, thus be removed from the entry text.
raw = raw[colon_pos + 1 :].strip()
raw = raw[(colon_pos + 1):].strip()
else:
date_blob_re = re.compile("(?:^|\n)\\[([^\\]]+)\\] ")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: code is based on Journal._parse with slight adaptions. E.g. the default_hour and default_minute handling is added.

@@ -51,6 +51,13 @@ Feature: Reading and writing to journal with custom date formats
| little_endian_dates.yaml | 2032-02-01: Test. | 01.02.2032 09:00 Test. |
| little_endian_dates.yaml | 2020-01-01: Test. | 01.01.2020 09:00 Test. |
| little_endian_dates.yaml | 2020-12-31: Test. | 31.12.2020 09:00 Test. |
# @todo: is it fine that default time be used here and not 00:00?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is this behavior fine?

@@ -78,6 +85,14 @@ Feature: Reading and writing to journal with custom date formats
Then the output should contain "10.05.2013 09:00 I saw Elvis."
And the output should contain "He's alive."

Scenario: Writing an entry at the prompt with custom date in bracket format
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: could be integrated into test above as config

| config_file | command |
| simple.yaml | [2013-07-20] Best day of my life! * |
| empty_folder.yaml | [2013-07-20] Best day of my life! * |
# Note: this one fail due to whitespace, cmp. next config
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I assume the dayone Journal should also be supported without issues? Will have to check that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support bracketed date style when composing new entry
1 participant